; Music of Grand Prix Simulator 2 (1989) (Codemasters) (David Whittaker)
; Ripped by Megachur the 14/01/2007

	write "GRANDPS2.BIN"

music_date_rip	equ &0e17
music_adr	equ &9fac
first_theme	equ 0
last_theme	equ 0

	read "music_header_v1_0.asm"

;9fac
;
.init_music
;
	push af
	call la274
	pop af
	ld c,a
	add a
	add c
	add a
	add c
	ld c,a
	ld b,#00
	ld hl,laa59
	add hl,bc
	ld a,(hl)
	ld (la08b),a
	inc hl
	ld ix,la016
	ld c,#22
	ld a,#03
.l9fca
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	push hl
	ld (ix+#10),#01
	ld (ix+#00),b
	ld (ix+#1d),b
	ld (ix+#1f),b
	ld (ix+#20),b
	ld hl,la586
	ld (ix+#0b),l
	ld (ix+#09),l
	ld (ix+#0c),h
	ld (ix+#0a),h
	ld (ix+#03),e
	ld (ix+#04),d
	ex de,hl
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld (ix+#05),#02
	ld (ix+#06),b
	pop hl
	ld (ix+#01),e
	ld (ix+#02),d
	add ix,bc
	dec a
	jr nz,l9fca
	ld (la407),a
	dec a
	ld (la5f5),a
	ld (la5ee),a
	ret
.la016
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#09
.la038
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#12
.la05a
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#24
;
.play_music
;
	call la708
	ld a,(la5ee)
	and a
	jr z,la0d6
.la086 equ $ + 1
	ld a,#00
	ld (la0d2),a
.la08b equ $ + 1
	ld a,#01
	ld hl,la5f5
	add (hl)
	ld (hl),a
	jr nc,la0aa
	ld b,#00
	ld ix,la016
	call la30f
	ld ix,la038
	call la30f
	ld ix,la05a
	call la30f
.la0aa
	ld ix,la016
	call la3d4
	ld (la4c3),hl
	ld (la4cb),a
	ld ix,la038
	call la3d4
	ld (la4c5),hl
	ld (la4cc),a
	ld ix,la05a
	call la3d4
	ld (la4c7),hl
	ld (la4cd),a
.la0d2 equ $ + 1
	ld a,#00
	ld (la4c9),a
.la0d6
	ld a,(la5ee)
	and a
	jr nz,la0ec
	ld (la4cb),a
	ld (la4cc),a
	ld (la4cd),a
	ld a,#3f
	ld (la4ca),a
	jr la114
.la0ec
	ld a,(la5ed)
	and #0f
	xor #0f
	jr z,la114
	ld b,a
	ld a,(la4cb)
	sub b
	jr nc,la0fd
	xor a
.la0fd
	ld (la4cb),a
	ld a,(la4cc)
	sub b
	jr nc,la107
	xor a
.la107
	ld (la4cc),a
	ld a,(la4cd)
	sub b
	jr nc,la111
	xor a
.la111
	ld (la4cd),a
.la115 equ $ + 1
.la114
	ld a,#00
	xor #ff
	ld (la115),a
	ld a,(la5f2)
	and a
	jr z,la14a
	ld a,(la4ca)
	or #09
	and #fe
	ld (la4ca),a
	ld a,#0a
	ld (la4cb),a
.la131 equ $ + 1
	ld hl,#0000
	ld a,(laa55)
	and #3f
	ld e,a
	ld d,#00
	sbc hl,de
	ld a,(la115)
	or a
	jr z,la147
	srl h
	rr l
.la147
	ld (la4c3),hl
.la14a
	ld a,(la5f3)
	and a
	jr z,la179
	ld a,(la4ca)
	or #12
	and #fd
	ld (la4ca),a
	ld a,#0a
	ld (la4cc),a
.la160 equ $ + 1
	ld hl,#0000
	ld a,(laa56)
	and #3f
	ld e,a
	ld d,#00
	sbc hl,de
	ld a,(la115)
	or a
	jr nz,la176
	srl h
	rr l
.la176
	ld (la4c5),hl
.la179
	ld a,(la5f4)
	and a
	jr z,la1a8
	ld a,(la4ca)
	or #24
	and #fb
	ld (la4ca),a
	ld a,#0a
	ld (la4cd),a
.la18f equ $ + 1
	ld hl,#0000
	ld a,(laa57)
	and #3f
	ld e,a
	ld d,#00
	sbc hl,de
	ld a,(la115)
	or a
	jr z,la1a5
	srl h
	rr l
.la1a5
	ld (la4c7),hl
.la1a8
	ld a,(la5ef)
	and a
	jr z,la1d0
	ld hl,(la4d0)
	ld (la4c3),hl
	ld a,(la9b8)
	ld b,a
	bit 3,a
	jr nz,la1c2
	ld a,(la4d6)
	ld (la4c9),a
.la1c2
	ld hl,la4ca
	ld a,(hl)
	or #09
	and b
	ld (hl),a
	ld a,(la4d8)
	ld (la4cb),a
.la1d0
	ld a,(la5f0)
	and a
	jr z,la1fa
	ld hl,(la4d2)
	ld (la4c5),hl
	ld a,(la9cd)
	ld b,a
	bit 3,a
	jr nz,la1ea
	ld a,(la4d6)
	ld (la4c9),a
.la1ea
	ld hl,la4ca
	ld a,(hl)
	or #12
	rlc b
	and b
	ld (hl),a
	ld a,(la4d9)
	ld (la4cc),a
.la1fa
	ld a,(la5f1)
	and a
	jr z,la226
	ld hl,(la4d4)
	ld (la4c7),hl
.la208 equ $ + 2
	ld a,(la9e2)
	ld b,a
	bit 3,a
	jr nz,la214
	ld a,(la4d6)
	ld (la4c9),a
.la214
	ld hl,la4ca
	ld a,(hl)
	or #24
	rlc b
	rlc b
	and b
	ld (hl),a
	ld a,(la4da)
	ld (la4cd),a
.la226
	ld hl,la4cd
	ld d,#0a
.la22b
	ld e,(hl)
	ld b,#f4
	out (c),d
	ld bc,#f600
	out (c),c
	ld a,#c0
	out (c),a
	out (c),c
	ld b,#f4
	out (c),e
	ld b,#f6
	add a
	out (c),a
	out (c),c
	dec hl
	dec d
	jp p,la22b
	ret
.la24c
	ld de,#0a00
.la24f
	call la259
	dec d
	jp p,la24f
	ld de,#073f
.la259
	ld b,#f4
	out (c),d
	ld bc,#f600
	out (c),c
	ld a,#c0
	out (c),a
	out (c),c
	ld b,#f4
	out (c),e
	ld b,#f6
	add a
	out (c),a
	out (c),c
	ret
;
.stop_music
.la274
;
	xor a
	ld (la5ee),a
	ld (la5f2),a
	ld (la5f3),a
	ld (la5f4),a
	call laa2d
	xor a
	ld (la4cb),a
	ld (la4cc),a
	ld (la4cd),a
	ret
	db #10,#5e,#4f,#3a,#00,#00,#6c,#05
	db #70,#71,#00,#4d
	pop hl
	jp la274
	ld c,(ix+#05)
	ld b,(ix+#06)
	ld l,(ix+#03)
	ld h,(ix+#04)
	add hl,bc
	inc bc
	inc bc
	ld a,(hl)
	inc hl
	ld d,(hl)
	ld e,a
	or d
	jr nz,la2c1
	ld l,(ix+#03)
	ld h,(ix+#04)
	ld bc,#0002
	ld e,(hl)
	inc hl
	ld d,(hl)
.la2c1
	ld (ix+#05),c
	ld (ix+#06),b
	ld b,#00
	jp la31c
	ld a,(ix+#21)
	ld c,a
	and #38
	ld hl,la48e
	xor (hl)
	and c
	xor (hl)
	ld (hl),a
	xor a
	ld (ix+#1e),a
	jp la31c
	ld a,(de)
	inc de
	ld (la407),a
	jr la31c
	ld a,(de)
	inc de
	ld (ix+#20),a
	jr la31c
	ld a,(de)
	ld (ix+#1b),a
	inc de
	ld a,(de)
	ld (ix+#1a),a
	ld (ix+#1c),a
	inc de
	ld (ix+#1d),#40
	jr la31c
	set 1,(ix+#00)
	jr la31c
	jr la347
	ld (ix+#1f),#ff
	jr la31c
.la30f
	dec (ix+#10)
	ret nz
	ld (ix+#00),b
	ld e,(ix+#01)
	ld d,(ix+#02)
.la31c
	ld a,(de)
	inc de
	and a
	jp m,la389
	ld (ix+#12),a
	bit 0,(ix+#1e)
	jr z,la32e
	ld (la086),a
.la32e
	ld l,(ix+#14)
	ld (ix+#16),l
	ld h,(ix+#15)
	ld (ix+#17),h
	ld a,(hl)
	ld (ix+#18),a
	ld (ix+#13),a
	ld a,(ix+#0f)
	ld (ix+#19),a
.la347
	set 5,(ix+#00)
	ld a,(ix+#11)
	ld (ix+#10),a
	ld (ix+#02),d
	ld (ix+#01),e
	ld a,(ix+#1f)
	and a
	jr z,la388
	ld a,(la5ef)
	and a
	jr z,la36a
	ld a,(la9b8)
	bit 3,a
	jr z,la388
.la36a
	ld a,(la5f0)
	and a
	jr z,la377
	ld a,(la9cd)
	bit 3,a
	jr z,la388
.la377
	ld a,(la5f1)
	and a
	jr z,la384
	ld a,(la9e2)
	bit 3,a
	jr z,la388
.la384
	ld (ix+#1f),#ff
.la388
	ret
.la389
	cp #c0
	jr c,la3cc
	add #20
	jr c,la3ad
	add #10
	jr c,la3b4
	add #10
	ld c,a
	ld hl,la584
	add hl,bc
	ld c,(hl)
	add hl,bc
	ld (ix+#0b),l
	ld (ix+#09),l
	ld (ix+#0c),h
	ld (ix+#0a),h
	jp la31c
.la3ad
	inc a
	ld (ix+#11),a
	jp la31c
.la3b4
	ld hl,la58f
	add a
	ld c,a
	add hl,bc
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	ld (ix+#14),l
	ld (ix+#15),h
	dec hl
	ld a,(hl)
	ld (ix+#0f),a
	jp la31c
.la3cc
	ld hl,la208
	ld c,a
	add hl,bc
	ld c,(hl)
	add hl,bc
	jp (hl)
.la3d4
	ld c,(ix+#00)
	bit 5,c
	jr z,la406
	ld a,(ix+#19)
	sub #01
	ld (ix+#19),a
	jr nc,la400
	ld a,(ix+#0f)
	ld (ix+#19),a
	ld l,(ix+#16)
	ld h,(ix+#17)
	inc hl
	ld a,(hl)
	and a
	jp m,la400
	ld (ix+#16),l
	ld (ix+#17),h
	ld (ix+#18),a
.la400
	ld a,(ix+#18)
	ld (ix+#13),a
.la407 equ $ + 1
.la406
	ld a,#00
	add (ix+#12)
	add (ix+#20)
	ld b,a
	ld l,(ix+#0b)
	ld h,(ix+#0c)
	ld a,(hl)
	inc hl
	and a
	jp p,la423
	ld l,(ix+#09)
	ld h,(ix+#0a)
	and #7f
.la423
	ld (ix+#0b),l
	ld (ix+#0c),h
	add b
	ld hl,la4dc
	ld d,#00
	add a
	ld e,a
	add hl,de
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld l,(ix+#1d)
	bit 6,l
	jr z,la484
	ld h,a
	ld b,(ix+#1a)
	sla b
	bit 7,l
	ld a,(ix+#1c)
	jr z,la44d
	bit 0,c
	jr nz,la46b
.la44d
	bit 5,l
	jr nz,la45d
	sub (ix+#1b)
	jr nc,la468
	set 5,(ix+#1d)
	sub a
	jr la468
.la45d
	add (ix+#1b)
	cp b
	jr c,la468
	res 5,(ix+#1d)
	ld a,b
.la468
	ld (ix+#1c),a
.la46b
	ex de,hl
	srl b
	sub b
	ld e,a
	ld a,d
	ld d,#00
	jr nc,la476
	dec d
.la476
	add #a0
	jr c,la482
.la47a
	sla e
	rl d
	add #18
	jr nc,la47a
.la482
	add hl,de
	ex de,hl
.la484
	ld a,c
	xor #01
	ld (ix+#00),a
	cpl
	and #03
.la48e equ $ + 1
	ld a,#38
	jr nz,la49b
	ld a,(la086)
	xor #08
	ld (la0d2),a
	ld a,#07
.la49b
	ld hl,la4ca
	xor (hl)
	and (ix+#21)
	xor (hl)
	ld (hl),a
	ld a,(ix+#1f)
	and a
	jp p,la4be
	and #7f
	ld (ix+#1f),a
	ld a,(ix+#21)
	and #38
	xor #ff
	and (hl)
	ld (hl),a
	ld a,#41
	ld (la0d2),a
.la4be
	ex de,hl
	ld a,(ix+#13)
	ret
.la4ca equ $ + 7
.la4c9 equ $ + 6
.la4c7 equ $ + 4
.la4c5 equ $ + 2
.la4c3
	db #00,#00,#00,#00,#00,#00,#00,#3f
.la4d2 equ $ + 7
.la4d1 equ $ + 6
.la4d0 equ $ + 5
.la4cd equ $ + 2
.la4cc equ $ + 1
.la4cb
	db #0f,#0f,#0f,#00,#00,#00,#00,#00
.la4da equ $ + 7
.la4d9 equ $ + 6
.la4d8 equ $ + 5
.la4d6 equ $ + 3
.la4d5 equ $ + 2
.la4d4 equ $ + 1
.la4d3
	db #00,#00,#00,#00,#3f,#10,#00,#10
	db #00
.la4dc
	dw #077c,#0708,#06b0,#0640
	dw #05ec,#0594,#0544,#04f8
	dw #04b0,#0470,#042c,#03f0
	dw #03be,#0384,#0358,#0320
	dw #02f6,#02ca,#02a2,#027c
	dw #0258,#0238,#0216,#01f8
	dw #01df,#01c2,#01ac,#0190
	dw #017b,#0165,#0151,#013e
	dw #012c,#011c,#010b,#00fc
	dw #00ef,#00e1,#00d6,#00c8
	dw #00bd,#00b2,#00a8,#009f
	dw #0096,#008e,#0085,#007e
	dw #0077,#0070,#006b,#0064
	dw #005e,#0059,#0054,#004f
	dw #004b,#0047,#0042,#003f
	dw #003b,#0038,#0035,#0032
	dw #002f,#002c,#002a,#0027
	dw #0025,#0023,#0021,#001f
	dw #001d,#001c,#001a,#0019
	dw #0017,#0016,#0015,#0013
	dw #0012,#0011,#0010,#000f
.la586 equ $ + 2
.la584
	db #02,#02,#80,#0c,#00,#00,#00,#00
	db #00,#00,#80
.la58f
	dw la59c,la5a8,la5ba,la5c1
	dw la5c8,la5e2
.la59c equ $ + 1
	db #01,#0f,#0e,#0d,#0c,#0b,#0a,#09
.la5a8 equ $ + 5
	db #08,#07,#06,#87,#01,#0f,#0f,#0d
	db #0b,#0d,#0c,#0a,#09,#0b,#0a,#08
.la5ba equ $ + 7
	db #07,#09,#08,#06,#05,#87,#01,#0f
.la5c1 equ $ + 6
	db #0e,#0d,#0c,#0b,#87,#01,#0f,#0f
.la5c8 equ $ + 5
	db #0e,#0d,#0c,#87,#01,#0f,#0e,#0d
	db #01,#0c,#01,#0b,#01,#0a,#01,#09
	db #01,#08,#01,#07,#01,#06,#01,#05
.la5e2 equ $ + 7
	db #01,#04,#01,#02,#01,#87,#01,#0e
	db #0d,#0c,#0b,#0a,#09,#0b,#0a,#09
.la5f2 equ $ + 7
.la5f1 equ $ + 6
.la5f0 equ $ + 5
.la5ef equ $ + 4
.la5ee equ $ + 3
.music_end equ $ + 3
.la5ed equ $ + 2
	db #08,#87,#0f,#00,#00,#00,#00,#00
.la5f5 equ $ + 2
.la5f4 equ $ + 1
.la5f3
	db #00,#00,#00
	ld hl,la9b1
	ld (hl),b
	ld hl,la603
	ld b,#00
	add hl,bc
	ld c,(hl)
	add hl,bc
	jp (hl)
.la603
	inc bc
	ld e,b
	xor l
	ld hl,la5ef
	ld (hl),#00
	ld hl,la934
	add a
	add l
	ld l,a
	jr nc,la614
	inc h
.la614
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld b,#0e
	ld hl,la9b2
.la61c
	ld a,(de)
	ld (hl),a
	inc hl
	inc de
	djnz la61c
	ld a,(la9b3)
	ld (la9c0),a
	ld hl,(la9b4)
	ld (la4d0),hl
	ld a,(la9b8)
	bit 3,a
	jr nz,la639
	ld a,l
	ld (la4d6),a
.la639
	ld a,(la9bd)
	ld (la9c1),a
	ld a,(la9bf)
	ld (la9c6),a
	ld hl,la9a4
	ld a,(la9b1)
	ld c,a
	add hl,bc
	ld (la9c2),hl
	ld (la9c4),hl
	ld a,(hl)
	ld (la4d8),a
	ld hl,la5ef
	inc (hl)
	ret
	ld hl,la5f0
	ld (hl),#00
	ld hl,la934
	add a
	add l
	ld l,a
	jr nc,la66a
	inc h
.la66a
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld b,#0e
	ld hl,la9c7
.la672
	ld a,(de)
	ld (hl),a
	inc hl
	inc de
	djnz la672
	ld a,(la9c8)
	ld (la9d5),a
	ld hl,(la9c9)
	ld (la4d2),hl
	ld a,(la9cd)
	bit 3,a
	jr nz,la68f
	ld a,l
	ld (la4d6),a
.la68f
	ld a,(la9d2)
	ld (la9d6),a
	ld a,(la9d4)
	ld (la9db),a
	ld hl,la9a4
	ld a,(la9b1)
	ld c,a
	add hl,bc
	ld (la9d7),hl
	ld (la9d9),hl
	ld a,(hl)
	ld (la4d9),a
	ld hl,la5f0
	inc (hl)
	ret
	ld hl,la5f1
	ld (hl),#00
	ld hl,la934
	add a
	add l
	ld l,a
	jr nc,la6c0
	inc h
.la6c0
	ld e,(hl)
	inc hl
	ld d,(hl)
	ld b,#0e
	ld hl,la9dc
.la6c8
	ld a,(de)
	ld (hl),a
	inc hl
	inc de
	djnz la6c8
	ld a,(la9dd)
	ld (la9ea),a
	ld hl,(la9de)
	ld (la4d4),hl
	ld a,(la9e2)
	bit 3,a
	jr nz,la6e5
	ld a,l
	ld (la4d6),a
.la6e5
	ld a,(la9e7)
	ld (la9eb),a
	ld a,(la9e9)
	ld (la9f0),a
	ld hl,la9a4
	ld a,(la9b1)
	ld c,a
	add hl,bc
	ld (la9ec),hl
	ld (la9ee),hl
	ld a,(hl)
	ld (la4da),a
	ld hl,la5f1
	inc (hl)
	ret
.la708
	call laa3a
	ld a,(la5ef)
	and a
	call nz,la7d0
	ld a,(la5f0)
	and a
	call nz,la882
	ld a,(la5f1)
	and a
	ret z
	ld a,(la9dc)
	and a
	jr nz,la72e
	ld a,(la9e8)
	and a
	jr nz,la72e
	ld (la5f1),a
	ret
.la72e
	dec a
	ld (la9dc),a
	ld a,(la9ea)
	and a
	jr nz,la766
	ld a,(la9e8)
	and a
	jr nz,la744
	ld a,(la9e5)
	and a
	jr z,la7a8
.la744
	dec a
	ld (la9e5),a
	ld a,(la9dd)
	ld (la9ea),a
	ld a,(la9e3)
	and a
	jr z,la757
	ld a,(laa57)
.la757
	ld b,a
	ld a,(la9de)
	add b
	ld (la4d4),a
	ld a,(la9df)
	add b
	ld (la4d5),a
.la766
	ld hl,la9ea
	dec (hl)
	ld hl,la9e9
	ld a,(hl)
	and a
	jr z,la778
	ld hl,la9f0
	dec (hl)
	jr nz,la79b
	ld (hl),a
.la778
	ld a,(la9e4)
	and a
	jr z,la79b
	jp p,la78e
	ld hl,(la4d4)
	ld de,(la9e0)
	add hl,de
	ld (la4d4),hl
	jr la79b
.la78e
	ld hl,(la4d4)
	ld de,(la9e0)
	and a
	sbc hl,de
	ld (la4d4),hl
.la79b
	ld a,(la9e2)
	bit 3,a
	jr nz,la7a8
	ld a,(la4d4)
	ld (la4d6),a
.la7a8
	ld a,(la9eb)
	dec a
	ld (la9eb),a
	jr nz,la7cf
	ld a,(la9e7)
	ld (la9eb),a
	ld hl,(la9ee)
	ld a,(hl)
	inc hl
	and a
	jp p,la7c9
	cp #80
	jr nz,la7cf
	ld hl,(la9ec)
	ld a,(hl)
	inc hl
.la7c9
	ld (la9ee),hl
	ld (la4da),a
.la7cf
	ret
.la7d0
	ld a,(la9b2)
	and a
	jr nz,la7e0
	ld a,(la9be)
	and a
	jr nz,la7e0
	ld (la5ef),a
	ret
.la7e0
	dec a
	ld (la9b2),a
	ld a,(la9c0)
	and a
	jr nz,la818
	ld a,(la9be)
	and a
	jr nz,la7f6
	ld a,(la9bb)
	and a
	jr z,la85a
.la7f6
	dec a
	ld (la9bb),a
	ld a,(la9b3)
	ld (la9c0),a
	ld a,(la9b9)
	and a
	jr z,la809
	ld a,(laa55)
.la809
	ld b,a
	ld a,(la9b4)
	add b
	ld (la4d0),a
	ld a,(la9b5)
	add b
	ld (la4d1),a
.la818
	ld hl,la9c0
	dec (hl)
	ld hl,la9bf
	ld a,(hl)
	and a
	jr z,la82a
	ld hl,la9c6
	dec (hl)
	jr nz,la84d
	ld (hl),a
.la82a
	ld a,(la9ba)
	and a
	jr z,la84d
	jp p,la840
	ld hl,(la4d0)
	ld de,(la9b6)
	add hl,de
	ld (la4d0),hl
	jr la84d
.la840
	ld hl,(la4d0)
	ld de,(la9b6)
	and a
	sbc hl,de
	ld (la4d0),hl
.la84d
	ld a,(la9b8)
	bit 3,a
	jr nz,la85a
	ld a,(la4d0)
	ld (la4d6),a
.la85a
	ld a,(la9c1)
	dec a
	ld (la9c1),a
	jr nz,la881
	ld a,(la9bd)
	ld (la9c1),a
	ld hl,(la9c4)
	ld a,(hl)
	inc hl
	and a
	jp p,la87b
	cp #80
	jr nz,la881
	ld hl,(la9c2)
	ld a,(hl)
	inc hl
.la87b
	ld (la9c4),hl
	ld (la4d8),a
.la881
	ret
.la882
	ld a,(la9c7)
	and a
	jr nz,la892
	ld a,(la9d3)
	and a
	jr nz,la892
	ld (la5f0),a
	ret
.la892
	dec a
	ld (la9c7),a
	ld a,(la9d5)
	and a
	jr nz,la8ca
	ld a,(la9d3)
	and a
	jr nz,la8a8
	ld a,(la9d0)
	and a
	jr z,la90c
.la8a8
	dec a
	ld (la9d0),a
	ld a,(la9c8)
	ld (la9d5),a
	ld a,(la9ce)
	and a
	jr z,la8bb
	ld a,(laa56)
.la8bb
	ld b,a
	ld a,(la9c9)
	add b
	ld (la4d2),a
	ld a,(la9ca)
	add b
	ld (la4d3),a
.la8ca
	ld hl,la9d5
	dec (hl)
	ld hl,la9d4
	ld a,(hl)
	and a
	jr z,la8dc
	ld hl,la9db
	dec (hl)
	jr nz,la8ff
	ld (hl),a
.la8dc
	ld a,(la9cf)
	and a
	jr z,la8ff
	jp p,la8f2
	ld hl,(la4d2)
	ld de,(la9cb)
	add hl,de
	ld (la4d2),hl
	jr la8ff
.la8f2
	ld hl,(la4d2)
	ld de,(la9cb)
	and a
	sbc hl,de
	ld (la4d2),hl
.la8ff
	ld a,(la9cd)
	bit 3,a
	jr nz,la90c
	ld a,(la4d2)
	ld (la4d6),a
.la90c
	ld a,(la9d6)
	dec a
	ld (la9d6),a
	jr nz,la933
	ld a,(la9d2)
	ld (la9d6),a
	ld hl,(la9d9)
	ld a,(hl)
	inc hl
	and a
	jp p,la92d
	cp #80
	jr nz,la933
	ld hl,(la9d7)
	ld a,(hl)
	inc hl
.la92d
	ld (la9d9),hl
	ld (la4d9),a
.la933
	ret
.la934
	dw la942,la950,la95e,la96c
	dw la97a,la988,la996
.la942
	db #06,#05,#47,#03,#20,#00,#f6,#00
.la950 equ $ + 6
	db #ff,#63,#00,#03,#00,#00,#14,#06
	db #01,#02,#c8,#00,#f6,#00,#ff,#ff
.la95e equ $ + 4
	db #00,#02,#00,#00,#32,#0a,#0a,#00
	db #03,#00,#f6,#01,#ff,#0a,#00,#04
.la96c equ $ + 2
	db #00,#00,#11,#05,#c7,#00,#20,#00
	db #f6,#00,#ff,#63,#00,#01,#00,#00
.la97a
	db #1e,#63,#11,#06,#10,#00,#fe,#00
.la988 equ $ + 6
	db #ff,#ff,#00,#04,#00,#00,#0f,#03
	db #60,#00,#08,#00,#fe,#00,#ff,#63
.la996 equ $ + 4
	db #00,#01,#00,#00,#14,#02,#28,#00
	db #02,#00,#fe,#00,#ff,#ff,#00,#02
.la9a4 equ $ + 2
	db #00,#00,#0f,#0e,#0d,#0c,#0b,#0a
.la9b1 equ $ + 7
	db #09,#08,#07,#06,#05,#04,#ff,#00
.la9b9 equ $ + 7
.la9b8 equ $ + 6
.la9b6 equ $ + 4
.la9b5 equ $ + 3
.la9b4 equ $ + 2
.la9b3 equ $ + 1
.la9b2
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9c1 equ $ + 7
.la9c0 equ $ + 6
.la9bf equ $ + 5
.la9be equ $ + 4
.la9bd equ $ + 3
.la9bb equ $ + 1
.la9ba
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9c9 equ $ + 7
.la9c8 equ $ + 6
.la9c7 equ $ + 5
.la9c6 equ $ + 4
.la9c4 equ $ + 2
.la9c2
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9d0 equ $ + 6
.la9cf equ $ + 5
.la9ce equ $ + 4
.la9cd equ $ + 3
.la9cb equ $ + 1
.la9ca
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9d9 equ $ + 7
.la9d7 equ $ + 5
.la9d6 equ $ + 4
.la9d5 equ $ + 3
.la9d4 equ $ + 2
.la9d3 equ $ + 1
.la9d2
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9e0 equ $ + 6
.la9df equ $ + 5
.la9de equ $ + 4
.la9dd equ $ + 3
.la9dc equ $ + 2
.la9db equ $ + 1
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9e9 equ $ + 7
.la9e8 equ $ + 6
.la9e7 equ $ + 5
.la9e5 equ $ + 3
.la9e4 equ $ + 2
.la9e3 equ $ + 1
.la9e2
	db #00,#00,#00,#00,#00,#00,#00,#00
.la9f0 equ $ + 6
.la9ee equ $ + 4
.la9ec equ $ + 2
.la9eb equ $ + 1
.la9ea
	db #00,#00,#00,#00,#00,#00,#00
	ld hl,#0d00
	ld (la131),hl
	ld a,#ff
	ld (la5f2),a
	ret
	xor a
	ld (la5f2),a
	ld (la4cb),a
	ret
	ld hl,#0c80
	ld (la160),hl
	ld a,#ff
	ld (la5f3),a
	ret
	xor a
	ld (la5f3),a
	ld (la4cc),a
	ret
	ld hl,#0c00
	ld (la18f),hl
	ld a,#ff
	ld (la5f4),a
	ret
	xor a
	ld (la5f4),a
	ld (la4cd),a
	ret
.laa2d
	xor a
	ld (la5ef),a
	ld (la5f0),a
	ld (la5f1),a
	jp la24c
.laa3a
	ld a,(laa55)
	and #48
	adc #38
	sla a
	sla a
	ld hl,laa58
	rl (hl)
	dec hl
	rl (hl)
	dec hl
	rl (hl)
	dec hl
	rl (hl)
	ld a,(hl)
	ret
.laa58 equ $ + 3
.laa57 equ $ + 2
.laa56 equ $ + 1
.laa55
	db #ff,#80,#1b,#34
.laa59
	db #20
	dw laa8e,laa7c,laa9c
	db #2e
	dw labc9,labb7,labcf
	db #24
	dw lac51,lac45,lac5d
	db #28
	dw lacdc,lacce,lace0
	db #24
	dw ladc3,ladc1,ladc5
.laa7c
	dw laac2,laade,laac2,laade
	dw laaf3,lab08,laaf3,laade
	dw #0000
.laa8e
	dw lab1d,lab1d,ladf3,lab1d
	dw lab1d,ladf0,#0000
.laa9c
	dw lab6a,ladf3,lab6a,ladf0
	dw lab6a,ladf3,lab6a,ladf0
	dw ladfc,lab6a,ladf3,lab6a
	dw ladf0,lab6a,ladf3,lab6a
	dw ladf0,ladf6,#0000
.laac2
	db #d1,#88,#01,#01,#90,#8a,#e0,#0c
	db #18,#8d,#0c,#18,#0c,#18,#8d,#0c
	db #18,#0c,#18,#8d,#0c,#1f,#09,#15
.laade equ $ + 4
	db #8d,#0b,#17,#87,#13,#1f,#8d,#13
	db #1f,#13,#1f,#8d,#13,#1f,#13,#1f
	db #8d,#13,#1f,#13,#1f,#8d,#13,#1f
.laaf3 equ $ + 1
	db #87,#11,#1d,#8d,#11,#1d,#11,#1d
	db #8d,#11,#1d,#11,#1d,#8d,#11,#1d
.lab08 equ $ + 6
	db #11,#1d,#8d,#11,#1d,#87,#0e,#1a
	db #8d,#0e,#1a,#0e,#1a,#8d,#0e,#1a
	db #0e,#1a,#8d,#0e,#1a,#0e,#1a,#8d
.lab1d equ $ + 3
	db #0e,#1a,#87,#8a,#88,#01,#01,#d3
	db #e2,#28,#29,#28,#26,#e1,#28,#29
	db #d1,#e2,#26,#26,#26,#26,#e1,#26
	db #26,#d3,#e2,#28,#29,#28,#26,#e1
	db #28,#29,#d1,#e2,#2b,#2d,#2b,#2d
	db #e1,#2b,#2a,#d3,#e2,#29,#2b,#29
	db #28,#e1,#29,#28,#d1,#e2,#26,#26
	db #26,#26,#e1,#26,#26,#d3,#e2,#29
	db #2b,#29,#28,#e1,#29,#2a,#e2,#2b
	db #2d,#2b,#29,#e1,#2b,#2d,#c1,#87
.lab6a
	db #8a,#88,#01,#01,#c1,#d3,#e2,#2b
	db #2d,#2b,#29,#e1,#2b,#2d,#d1,#e2
	db #2b,#2d,#2b,#2d,#e1,#2b,#2d,#d3
	db #e2,#2b,#2d,#2b,#29,#e1,#2b,#2d
	db #d1,#e2,#2f,#30,#2f,#30,#e1,#2f
	db #2e,#d3,#e2,#2d,#2f,#2d,#2b,#e1
	db #2d,#2b,#d1,#e2,#29,#29,#29,#29
	db #e1,#29,#29,#d3,#e2,#2d,#2f,#2d
	db #2b,#e1,#2d,#2e,#e2,#2f,#30,#2f
	db #2d,#e1,#2f,#30,#87
.labb7
	dw labd5,labd5,labec,labec
	dw labd5,labd5,labec,labec
.labc9 equ $ + 2
	dw labfd,lac0b,lac0b,lac01
.labcf
	dw lac08,lac08,lac41
.labd5
	db #88,#01,#01,#90,#8a,#d0,#e1,#18
	db #e0,#18,#8d,#18,#8f,#18,#e1,#18
.labec equ $ + 7
	db #e0,#18,#8d,#18,#8f,#18,#87,#e1
	db #11,#e0,#11,#8d,#11,#8f,#11,#e1
	db #11,#e0,#11,#8d,#11,#8f,#11,#87
.lac01 equ $ + 4
.labfd
	db #e8,#d4,#1c,#8e,#88,#01,#01,#e8
.lac0b equ $ + 6
.lac08 equ $ + 3
	db #d4,#1f,#8e,#88,#01,#01,#8a,#d5
	db #e0,#1f,#22,#24,#1f,#22,#24,#1f
	db #22,#24,#1f,#22,#24,#1f,#22,#24
	db #1f,#22,#24,#1f,#22,#24,#1f,#22
	db #24,#1d,#22,#24,#1d,#22,#24,#1d
	db #22,#24,#1d,#22,#24,#1d,#22,#24
	db #1d,#22,#24,#1d,#22,#24,#1d,#22
.lac41 equ $ + 4
	db #24,#92,#0c,#87,#e8,#d4,#18,#8e
.lac45
	dw lac69,lac69,lac81,lac81
.lac51 equ $ + 4
	dw lac69,lac92,laca0,laca0
	dw lacb6,lacb6,laca0,lac96
.lac5d
	dw lac9d,lac9d,lacb6,lacb6
	dw lac9d,lacca
.lac69
	db #88,#01,#01,#90,#8a,#d1,#e0,#13
	db #13,#13,#13,#13,#13,#13,#13,#13
	db #13,#13,#13,#13,#13,#13,#13,#87
.lac81
	db #0c,#0c,#0c,#0c,#0c,#0c,#0c,#0c
	db #0c,#0c,#0c,#0c,#0c,#0c,#0c,#0c
.lac96 equ $ + 5
.lac92 equ $ + 1
	db #87,#d4,#e7,#13,#8e,#88,#01,#01
.laca0 equ $ + 7
.lac9d equ $ + 4
	db #d4,#e7,#18,#8e,#88,#01,#01,#8a
	db #d3,#e1,#13,#20,#e0,#13,#e1,#1f
	db #e0,#13,#e1,#1b,#e0,#13,#e1,#1a
.lacb6 equ $ + 5
	db #e0,#13,#e1,#16,#87,#e1,#18,#20
	db #e0,#18,#e1,#1f,#e0,#18,#e1,#1b
	db #e0,#18,#e1,#1a,#e0,#18,#e1,#16
.lacca equ $ + 1
	db #87,#d4,#e5,#1f,#8e
.lacce
	dw lace4,ladf9,lace4,ladfc
.lacdc equ $ + 6
	dw lace4,ladf6,#0000,lad25
.lace0 equ $ + 2
	dw #0000,lad73,#0000
.lace4
	db #88,#01,#01,#90,#92,#05,#8a,#d1
	db #e3,#11,#11,#e2,#11,#e0,#11,#e3
	db #18,#18,#e2,#18,#e0,#18,#e3,#13
	db #13,#e2,#13,#e0,#13,#e3,#1a,#1a
	db #e2,#1a,#e0,#1a,#e3,#11,#11,#e2
	db #11,#e0,#11,#e3,#18,#18,#e2,#18
	db #e0,#18,#e3,#13,#13,#e2,#13,#e0
	db #13,#e3,#13,#13,#e2,#13,#e0,#13
.lad25 equ $ + 1
	db #87,#88,#01,#01,#92,#05,#8a,#d2
	db #e5,#1d,#e0,#1d,#1d,#e2,#1d,#e0
	db #1d,#e5,#24,#e0,#24,#24,#e2,#24
	db #e0,#24,#e5,#23,#e0,#23,#23,#e2
	db #23,#e0,#23,#e5,#26,#e0,#26,#26
	db #e1,#26,#26,#e5,#1d,#e0,#1d,#1d
	db #e2,#1d,#e0,#1d,#e5,#24,#e0,#24
	db #24,#e2,#24,#e0,#24,#e5,#23,#e0
	db #23,#23,#e2,#23,#e0,#23,#e5,#26
.lad73 equ $ + 7
	db #e0,#2b,#2b,#e1,#2b,#2b,#87,#88
	db #01,#01,#92,#05,#8a,#d2,#e5,#21
	db #e0,#21,#21,#e2,#21,#e0,#21,#e5
	db #28,#e0,#28,#28,#e2,#28,#e0,#28
	db #e5,#26,#e0,#26,#26,#e2,#26,#e0
	db #26,#e5,#21,#e0,#21,#21,#e1,#21
	db #21,#e5,#21,#e0,#21,#21,#e2,#21
	db #e0,#21,#e5,#28,#e0,#28,#28,#e2
	db #28,#e0,#28,#e5,#26,#e0,#26,#26
	db #e2,#26,#e0,#26,#e5,#2b,#e0,#2f
	db #2f,#e1,#2f,#2f,#87
.ladc5 equ $ + 4
.ladc3 equ $ + 2
.ladc1
	dw ladc7,ladd6,lade3
.ladc7
	db #88,#01,#01,#8a,#d3,#89,#01,#e0
.ladd6 equ $ + 7
	db #1d,#e2,#20,#d4,#e5,#21,#8e,#88
	db #01,#01,#8a,#d3,#e0,#29,#e2,#2c
.lade3 equ $ + 4
	db #d4,#e5,#29,#8e,#88,#01,#01,#8a
	db #d3,#e0,#24,#e2,#27,#d4,#e5,#24
.ladf6 equ $ + 7
.ladf3 equ $ + 4
.ladf0 equ $ + 1
	db #8e,#92,#00,#87,#92,#0c,#87,#89
.ladf9 equ $ + 2
	db #00,#87,#89,#01,#87
.ladfc
	db #89,#03,#87


.game_name
	db "Grand Prix Simulator 2",0
.game_year
	db "1989",0
.game_publisher
	db "Codemasters",0
.music_author
	db "David Whittaker",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
